namespace LogikBug
{
	///<summary>
	/// Provides a base class for disposable objects.
	///</summary>
	public abstract class DisposableObject : IDisposableObject
	{
		#region IDisposableObject Members

		/// <summary>
		/// True if the object has been disposed of, False if it has not.
		/// </summary>
		public virtual bool IsDisposed { get; protected set; }

		///<summary>
		/// True if the current object is in the
		/// process of disposing, False if it is not.
		///</summary>
		public virtual bool IsDisposing { get; protected set; }

		/// <summary>
		/// Performs application-defined tasks associated with 
		/// freeing, releasing, or resetting unmanaged resources.
		/// </summary>
		/// <param name="isDisposing">Determines if the current object is disposing.</param>
		public virtual void Dispose(bool isDisposing)
		{
			if (!IsDisposed && isDisposing && !IsDisposing)
			{
				IsDisposing = false;

				DisposeResources();

				IsDisposed = true;
			}
		}

		/// <summary>
		/// Performs application-defined tasks associated with 
		/// freeing, releasing, or resetting unmanaged resources.
		/// </summary>
		/// <filterpriority>2</filterpriority>
		protected internal abstract void DisposeResources();

		#endregion

		#region IDisposable Members

		/// <summary>
		/// Performs application-defined tasks associated with 
		/// freeing, releasing, or resetting unmanaged resources.
		/// </summary>
		/// <filterpriority>2</filterpriority>
		public virtual void Dispose()
		{
			Dispose(true);
		}

		#endregion
	}
}